﻿<UserControl x:Class="Demo.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             
		xmlns:riac="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
		xmlns:domain="clr-namespace:Demo.Web"
		xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"						 
             
    mc:Ignorable="d"
    d:DesignHeight="800" d:DesignWidth="480">

  <Grid x:Name="LayoutRoot" Background="White">
    <Grid.Resources>
      <Style x:Key="ElementStyle_right" TargetType="TextBlock">
        <Setter Property="TextAlignment" Value="Right"/>
      </Style>
      <Style x:Key="styleLabel1" TargetType="TextBlock">
        <Setter  Property="Margin" Value="10,3,5,3"/>
        <Setter Property="HorizontalAlignment" Value="Right" />
        <Setter Property="VerticalAlignment" Value="Center" />
      </Style>
      <Style x:Key="styleLabel2" TargetType="TextBlock">
        <Setter  Property="Margin" Value="10,0,5,0"/>
        <Setter Property="HorizontalAlignment" Value="Center" />
        <Setter Property="VerticalAlignment" Value="Center" />
      </Style>
      <Style x:Key="styleBox1" TargetType="TextBox">
        <Setter Property="Margin" Value="0,2,0,2" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
      </Style>
      <Style x:Key="styleColor" TargetType="TextBox">
        <Setter Property="Width" Value="80"/>
        <Setter Property="Margin" Value="0,2,0,2" />
      </Style>
    </Grid.Resources>

    
    <riac:DomainDataSource x:Name="dsProducts" AutoLoad="True" QueryName="GetProduct" LoadSize="30" >
      <riac:DomainDataSource.DomainContext>
        <domain:TestDomainContext />
      </riac:DomainDataSource.DomainContext>
      <riac:DomainDataSource.QueryParameters>
        <riac:Parameter ParameterName="filter"  />
      </riac:DomainDataSource.QueryParameters>
      <riac:DomainDataSource.SortDescriptors>
        <riac:SortDescriptor PropertyPath="Name" Direction="Ascending" />
      </riac:DomainDataSource.SortDescriptors>
    </riac:DomainDataSource>

    <StackPanel Orientation="Vertical" Margin="0,20,0,0" Width="800">
      <TextBlock Text="Filter" FontWeight="Bold" FontSize="14" Margin="5,5,0,5" />
      <Border BorderThickness="1" HorizontalAlignment="Left" BorderBrush="#FF7791AA" Margin="0,0,0,10" Padding="8" CornerRadius="7">
        <Grid HorizontalAlignment="Left">
          <Grid.ColumnDefinitions>
            <ColumnDefinition  Width="Auto"/>
            <ColumnDefinition  Width="50"/>
            <ColumnDefinition  Width="30"/>
            <ColumnDefinition  Width="50"/>
            <ColumnDefinition  Width="*"/>
          </Grid.ColumnDefinitions>
          <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
          </Grid.RowDefinitions>
          <TextBlock Text="Price from" Style="{StaticResource styleLabel1}"  />
          <TextBox x:Name="txtPrice1" Grid.Column="1" Style="{StaticResource styleBox1}"/>
          <TextBlock Text="to" Grid.Column="2" Style="{StaticResource styleLabel1}"/>
          <TextBox x:Name="txtPrice2" Grid.Column="3" Style="{StaticResource styleBox1}"/>

          <TextBlock Text="Size from" Style="{StaticResource styleLabel1}" Grid.Row="1"  />
          <TextBox x:Name="txtSize1" Grid.Row="1" Grid.Column="1" Style="{StaticResource styleBox1}"/>
          <TextBlock Text="to" Grid.Row="1" Grid.Column="2" Style="{StaticResource styleLabel1}" />
          <TextBox x:Name="txtSize2" Grid.Row="1" Grid.Column="3" Style="{StaticResource styleBox1}"/>

          <TextBlock Text="Color" Grid.Row="2" Style="{StaticResource styleLabel1}"/>
          <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="4">
            <TextBox  x:Name="txtColor1" Style="{StaticResource styleColor}"/>
            <TextBlock Text="or" Style="{StaticResource styleLabel1}"/>
            <TextBox x:Name="txtColor2" Style="{StaticResource styleColor}"/>
            <TextBlock Text="or" Style="{StaticResource styleLabel1}"/>
            <TextBox x:Name="txtColor3" Style="{StaticResource styleColor}"/>
          </StackPanel>

          <Button Grid.Row="3" Grid.ColumnSpan="5" Content="Search" Height="22" Width="100"  HorizontalAlignment="Right" Margin="0,15,0,10" Click="Button_Click"></Button>
        </Grid>
      </Border>
      <data:DataPager x:Name="dpTest" PageSize="10" Source="{Binding ElementName=dsProducts, Path=Data}"  ></data:DataPager>


      <data:DataGrid x:Name="dgProducts" Height="300" AutoGenerateColumns="False" 	  
				IsReadOnly="False"							
				ItemsSource="{Binding ElementName=dsProducts, Path=Data }"
				>
        <data:DataGrid.Columns>
          <data:DataGridTextColumn Header="Product"
						Width="150" MaxWidth="300" MinWidth="40" 
						Binding="{Binding Name}" />
          <data:DataGridTextColumn Header="Product Nr."
						Width="120" MaxWidth="300" MinWidth="40" 
						Binding="{Binding ProductNumber}"/>
          <data:DataGridTextColumn Header="Color"
						Width="70" MaxWidth="300" MinWidth="30" 
						Binding="{Binding Color, Mode=TwoWay}"/>
          <data:DataGridTextColumn Header="Size"
						Width="70" MaxWidth="300" MinWidth="30" 
						Binding="{Binding Size}"  ElementStyle="{StaticResource ElementStyle_right}"/>
          <data:DataGridTextColumn Header="Price"
						Width="90" MaxWidth="300" MinWidth="30" 
						Binding="{Binding ListPrice }" ElementStyle="{StaticResource ElementStyle_right}" />
          <data:DataGridTextColumn Header="Weight"
						Width="70" MaxWidth="300" MinWidth="30" 
						Binding="{Binding Weight}"  ElementStyle="{StaticResource ElementStyle_right}">
          </data:DataGridTextColumn>
          <data:DataGridTextColumn Header="Sell start date"
						Width="100" MaxWidth="300" MinWidth="30" 
						Binding="{Binding SellStartDate, StringFormat=d}"  ElementStyle="{StaticResource ElementStyle_right}"/>
        </data:DataGrid.Columns>
      </data:DataGrid>
    </StackPanel>
    
  </Grid>
</UserControl>
